/*
 * Copyright 2008-2023 dexian.vip. All rights reserved.
 * Support: http://www.dexian.vip
 * License: http://www.dexian.vip/license
 */

package vip.dexian.core.base.event;

import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.io.Serial;
import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * 领域事件基类
 *
 * @author 挺好的 2023年06月08日 9:14
 */
@Getter
@Setter
@NoArgsConstructor
public class BaseDomainEvent<T extends Serializable> implements Serializable {

    @Serial
    private static final long serialVersionUID = 7589418477045801614L;

    /**
     * 发生时间
     */
    private LocalDateTime occurredOn;

    /**
     * 领域事件数据
     */
    private T data;

    public BaseDomainEvent (T data) {
        this.data       = data;
        this.occurredOn = LocalDateTime.now();
    }
}
